<!--业务员结算政策列表-->
<template>
  <div>
    <f-search-form :more='false' @searchHandler='searchHandler'>
      <f-search-form-item label='业务员' name='saleManName' />
    </f-search-form>
    <f-table ref='table' style='margin-top: 5px' rowKey='policySaleManId' :tableColumns='columns' :scroll='{x:true}' :multiple='multiple' :autoLoad='false' :operator='operator' handler='policySaleManPageListHandler' :params='queryParam' :api='api.bps'>
         <span slot='baopiao' slot-scope='text, record, index'>
            <a-tag color='#FF0000' v-if='text==1'>
            包票
          </a-tag>
          <a-tag color='#00FF00' v-if='text==0'>
            不包票
          </a-tag>
        </span>
      <span slot='settleRule' slot-scope='text, record, index'>
              <a-tag color='#FF0000' v-if='text==1'>
              是
            </a-tag>
            <a-tag color='#00FF00' v-if='text==0'>
              否
            </a-tag>
      </span>
      <span slot='hasTaxRateDiff' slot-scope='text, record, index'>
              <a-tag color='#FF0000' v-if='text==1'>
              有
            </a-tag>
            <a-tag color='#00FF00' v-if='text==0'>
              无
            </a-tag>
      </span>
      <span slot='action' slot-scope='text, record'>
          <template>
            <a @click='$refs.saleManFormDrawer.showDrawer(record)'>编辑</a>
            <a-divider type='vertical' />
          </template>
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item>
                <a href='javascript:;' @click='$refs.table.del(record)'>删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
    </f-table>
    <policy-sale-man-form-drawer ref='saleManFormDrawer' @success='onSuccess' :policyDrugId='queryParam.policyDrugId'></policy-sale-man-form-drawer>
  </div>
</template>
<script>
import api from "../../../../js/api"
import PolicySaleManFormDrawer from "@/views/module/haiying/policy/settle/components/saleman/policy_saleman_form_drawer"

export default {
  name: "PolicyListSaleMan",
  components: { PolicySaleManFormDrawer },
  data() {
    let me = this
    //操作按钮
    let operator = []
    operator.push({
      name: "添加政策",
      icon: "plus",
      that: this,
      handler: (table) => {
        this.$refs.saleManFormDrawer.showDrawer()
      }
    })
    return {
      api: Object.assign(api, this.api),
      multiple: false,
      //列表初始化查询参数
      queryParam: {
        auth: 1,
        policyDrugId: ""
      },
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "left",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "部门名称",
          align: "center",
          width: "80px",
          dataIndex: "deptName"
        },
        {
          title: "业务员",
          align: "left",
          width: "80px",
          sorter: true,
          dataIndex: "saleManName"
        },
        {
          title: "业务编码",
          align: "left",
          width: "80px",
          sorter: true,
          dataIndex: "saleManBusinessNo"
        },
        {
          title: "职务",
          align: "left",
          width: "80px",
          sorter: true,
          dataIndex: "positionName"
        },
        {
          title: "结算价",
          align: "left",
          width: "60px",
          dataIndex: "saleManPrice"
        },
        {
          title: "结算标准",
          align: "left",
          width: "80px",
          dataIndex: "saleManRate"
        },
        {
          title: "每盒提成",
          align: "center",
          width: "60px",
          dataIndex: "rebateAmount"
        },
        {
          title: "结算公式",
          align: "left",
          ellipsis: true,
          width: "200px",
          dataIndex: "saleManSettleFormula"
        },
        {
          title: "执行日期",
          align: "center",
          width: "100px",
          dataIndex: "beginDate"
        },
        {
          title: "结束日期",
          align: "center",
          width: "100px",
          dataIndex: "endDate"
        },
        {
          title: "回款结算",
          align: "center",
          width: "80px",
          dataIndex: "settleRule",
          scopedSlots: { customRender: "settleRule" }
        },
        {
          title: "包票",
          align: "center",
          width: "60px",
          dataIndex: "baopiao",
          scopedSlots: { customRender: "baopiao" }
        },
        {
          title: "备注",
          align: "center",
          ellipsis: true,
          dataIndex: "remark"
        }, {
          title: "操作",
          align: "center",
          width: "110px",
          fixed: "right",
          dataIndex: "action",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    setData(data) {
      //设置列表初始查询条件
      this.queryParam.policyDrugId = data.policyDrugId
      this.$refs.table.refresh(false)
    },
    onSuccess() {
      this.$refs.table.refresh()
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },
    /**
     * 刷新列表
     */
    onLoad() {
      this.$refs.table.refresh()
      this.$emit("changeTab")
    }
  }
}
</script>